<?php
include_once dirname(__FILE__)."/../../config.inc.php";
include_once dirname(__FILE__)."/../database.php";

class RaceTable
{
    private static $_playableRaces;
    private static $_npgRaces;
    
    public static function playableRaces()
    {
        if(!count(RaceTable::$_playableRaces))
        {
            $db = new Database(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
            $db->connect();
            $res = $db->query("SELECT * FROM `races`");
            
            while($row = $db->fetch_array())
            {
                RaceTable::$_playableRaces[$row["ID"]] = $row["RaceName"];
            }
            
            $db->close();
        }
        
        return RaceTable::$_playableRaces;
    }
        
    public static function npgRaces()
    {
        if(!count(RaceTable::$_npgRaces))
        {
            $db = new Database(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
            $db->connect();
            $res = $db->query("SELECT * FROM `npg_races`");
            
            while($row = $db->fetch_array())
            {
                RaceTable::$_npgRaces[$row["ID"]] = $row["RaceName"];
            }
            
            $db->close();
        }
        
        return RaceTable::$_npgRaces;    
    }    
}
?>
